home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / dpmigcc5.zip / RSX / SOURCE / DOSERRNO.C < prev    next >
C/C++ Source or Header  |  1994-05-27  |  8KB  |  172 lines

  1. /*****************************************************************************
  2.  * FILE: doserrno.c                                 *
  3.  *                                         *
  4.  * DESC:                                     *
  5.  *    - msdos error no to EMX errno                         *
  6.  *    - EMX errno to DJGPP errno                         *
  7.  *                                         *
  8.  * Copyright (C) 1993,1994                             *
  9.  *    Rainer Schnitker, Heeper Str. 283, 33607 Bielefeld             *
  10.  *    email: rainer@mathematik.uni-bielefeld.de                 *
  11.  *                                         *
  12.  *****************************************************************************/
  13.  
  14. #include "DOSERRNO.H"
  15.  
  16. #define N_DOS_ERRORS 0x5A
  17.  
  18. #define EMX_RESERVED        EMX_EIO
  19.  
  20. static unsigned char dos_errors[N_DOS_ERRORS + 1] =
  21. {
  22.     0,                /* 0x00  no error                                 */
  23.     EMX_EINVAL,            /* 0x01  function number invalid                 */
  24.     EMX_ENOENT,            /* 0x02  file not found                          */
  25.     EMX_ENOENT,            /* 0x03  path not found                          */
  26.     EMX_EMFILE,            /* 0x04  too many open files                         */
  27.     EMX_EACCES,            /* 0x05  access denied                             */
  28.     EMX_EBADF,            /* 0x06  invalid handle                          */
  29.     EMX_EIO,            /* 0x07  memory control block destroyed          */
  30.     EMX_ENOMEM,            /* 0x08  insufficient memory                         */
  31.     EMX_EIO,            /* 0x09  memory block address invalid                 */
  32.     EMX_EINVAL,            /* 0x0A  environment invalid                         */
  33.     EMX_ENOEXEC,        /* 0x0B  format invalid                          */
  34.     EMX_EINVAL,            /* 0x0C  access code invalid                         */
  35.     EMX_EINVAL,            /* 0x0D  data invalid                                 */
  36.     EMX_RESERVED,        /* 0x0E  reserved                                 */
  37.     EMX_EACCES,            /* 0x0F  invalid drive                             */
  38.     EMX_EACCES,            /* 0x10  attempted to remove current directory     */
  39.     EMX_EXDEV,            /* 0x11  not same device                         */
  40.     EMX_ENOENT,            /* 0x12  no more files                             */
  41.     EMX_EIO,            /* 0x13  disk write-protected                         */
  42.     EMX_EIO,            /* 0x14  unknown unit                                 */
  43.     EMX_EIO,            /* 0x15  drive not ready                         */
  44.     EMX_EIO,            /* 0x16  unknown command                         */
  45.     EMX_EIO,            /* 0x17  data error                                 */
  46.     EMX_EIO,            /* 0x18  bad request structure length                 */
  47.     EMX_EIO,            /* 0x19  seek error                                 */
  48.     EMX_EIO,            /* 0x1A  unknown media type                         */
  49.     EMX_EIO,            /* 0x1B  sector not found                         */
  50.     EMX_ENOSPC,            /* 0x1C  printer out of paper                         */
  51.     EMX_EIO,            /* 0x1D  write fault                                 */
  52.     EMX_EIO,            /* 0x1E  read fault                                 */
  53.     EMX_EIO,            /* 0x1F  general failure                         */
  54.     EMX_EACCES,            /* 0x20  sharing violation                         */
  55.     EMX_EACCES,            /* 0x21  lock violation                          */
  56.     EMX_EIO,            /* 0x22  disk change invalid                         */
  57.     EMX_EIO,            /* 0x23  FCB unavailable                         */
  58.     EMX_EIO,            /* 0x24  sharing buffer overflow                 */
  59.     EMX_EIO,            /* 0x25  code page mismatch                         */
  60.     EMX_EIO,            /* 0x26  cannot complete file operation          */
  61.     EMX_ENOSPC,            /* 0x27  insufficient disk space                 */
  62.     EMX_RESERVED,        /* 0x28  reserved                                 */
  63.     EMX_RESERVED,        /* 0x29  reserved                                 */
  64.     EMX_RESERVED,        /* 0x2A  reserved                                 */
  65.     EMX_RESERVED,        /* 0x2B  reserved                                 */
  66.     EMX_RESERVED,        /* 0x2C  reserved                                 */
  67.     EMX_RESERVED,        /* 0x2D  reserved                                 */
  68.     EMX_RESERVED,        /* 0x2E  reserved                                 */
  69.     EMX_RESERVED,        /* 0x2F  reserved                                 */
  70.     EMX_RESERVED,        /* 0x30  reserved                                 */
  71.     EMX_RESERVED,        /* 0x31  reserved                                 */
  72.     EMX_EIO,            /* 0x32  network request not supported             */
  73.     EMX_EIO,            /* 0x33  remote computer not listening             */
  74.     EMX_EIO,            /* 0x34  duplicate name on network                 */
  75.     EMX_EIO,            /* 0x35  network name not found                  */
  76.     EMX_EIO,            /* 0x36  network busy                                 */
  77.     EMX_EIO,            /* 0x37  network device no longer exists         */
  78.     EMX_EIO,            /* 0x38  network BIOS command limit exceeded         */
  79.     EMX_EIO,            /* 0x39  network adapter hardware error          */
  80.     EMX_EIO,            /* 0x3A  incorrect response from network         */
  81.     EMX_EIO,            /* 0x3B  unexpected network error                 */
  82.     EMX_EIO,            /* 0x3C  incompatible remote adapter                 */
  83.     EMX_ENOSPC,            /* 0x3D  print queue full                         */
  84.     EMX_ENOSPC,            /* 0x3E  queue not full                          */
  85.     EMX_EIO,            /* 0x3F  not enough space to print file          */
  86.     EMX_EIO,            /* 0x40  network name was deleted                 */
  87.     EMX_EACCES,            /* 0x41  network: Access denied                  */
  88.     EMX_EIO,            /* 0x42  network device type incorrect             */
  89.     EMX_EIO,            /* 0x43  network name not found                  */
  90.     EMX_EIO,            /* 0x44  network name limit exceeded                 */
  91.     EMX_EIO,            /* 0x45  network BIOS session limit exceeded         */
  92.     EMX_EIO,            /* 0x46  temporarily paused                         */
  93.     EMX_EIO,            /* 0x47  network request not accepted                 */
  94.     EMX_EIO,            /* 0x48  network print/disk redirection paused     */
  95.     EMX_EACCES,            /* 0x49  invalid network version                 */
  96.     EMX_EIO,            /* 0x4A  account expired                         */
  97.     EMX_EIO,            /* 0x4B  password expired                         */
  98.     EMX_EIO,            /* 0x4C  login attempt invalid at this time         */
  99.     EMX_EIO,            /* 0x4D  disk limit exceeded on network node         */
  100.     EMX_EIO,            /* 0x4E  not logged in to network node             */
  101.     EMX_RESERVED,        /* 0x4F  reserved                                 */
  102.     EMX_EEXIST,            /* 0x50  file exists                                 */
  103.     EMX_RESERVED,        /* 0x51  reserved                                 */
  104.     EMX_ENOENT,            /* 0x52  cannot make directory                     */
  105.     EMX_EIO,            /* 0x53  fail on INT 24h                         */
  106.     EMX_EIO,            /* 0x54  too many redirections                     */
  107.     EMX_EIO,            /* 0x55  duplicate redirection                     */
  108.     EMX_EIO,            /* 0x56  invalid password                         */
  109.     EMX_EINVAL,            /* 0x57  invalid parameter                         */
  110.     EMX_EIO,            /* 0x58  network write fault                         */
  111.     EMX_EIO,            /* 0x59  function not supported on network         */
  112.     EMX_EIO            /* 0x5A  required system component not installed */
  113. };
  114.  
  115. static unsigned char emx2djgpp[] =
  116. {
  117.     0,
  118.     5,                /* 1  EPERM     Operation not permitted          */
  119.     2,                /* 2  ENOENT     No such file or directory          */
  120.     19,                /* 3  ESRCH     No such process              */
  121.     100,            /* 4  EINTR     Interrupted system call          */
  122.     101,            /* 5  EIO      I/O error                  */
  123.     101,
  124.     10,                /* 7  E2BIG     Arguments or environment too big     */
  125.     21,                /* 8  ENOEXEC     Invalid executable file format       */
  126.     6,                /* 9  EBADF     Bad file number              */
  127.     200,            /* 10 ECHILD     No child processes              */
  128.     103,            /* 11 EAGAIN     No more processes              */
  129.     8,                /* 12 ENOMEM     Not enough memory              */
  130.     5,                /* 13 EACCES     Permission denied              */
  131.     101,
  132.     101,
  133.     101,
  134.     36,                /* 17 EEXIST     File exists                  */
  135.     17,                /* 18 EXDEV     Cross-device link              */
  136.     101,
  137.     3,                /* 20 ENOTDIR     Not a directory              */
  138.     19,                /* 21 EISDIR     Is a directory               */
  139.     19,                /* 22 EINVAL     Invalid argument              */
  140.     101,
  141.     4,                /* 24 EMFILE     Too many open files              */
  142.     101,
  143.     101,
  144.     101,
  145.     102,            /* 28 ENOSPC     Disk full                  */
  146.     19,                /* 29 ESPIPE     Illegal seek                  */
  147.     5,                /* 30 EROFS     Read-only file system              */
  148.     101,
  149.     32,                /* 32 EPIPE     Broken pipe                  */
  150.     33,                /* 33 EDOM     Domain error                  */
  151.     34,                /* 34 ERANGE     Result too large              */
  152.     101,
  153.     101,
  154.     5,                /* 37 EMSDOS     Not supported under MS-DOS          */
  155.     19                /* 38 ENAMETOOLONG File name too long              */
  156. };
  157.  
  158. unsigned int doserror_to_errno(int error_dos)
  159. {
  160.     if (error_dos >= N_DOS_ERRORS)
  161.     return EMX_EIO;
  162.     else
  163.     return (unsigned) dos_errors[error_dos];
  164. }
  165.  
  166. unsigned int errno_djgpp(int emx_errno)
  167. {
  168.     if (emx_errno > 38)
  169.     emx_errno = EMX_EIO;
  170.     return (unsigned) emx2djgpp[emx_errno];
  171. }
  172.